package com.slt.concurrency.mashibing2019.juc.c_000_Thread.my;

import ch.qos.logback.core.pattern.FormatInfo;

/**
 *   继承Thread类
 *   实现Runnabale
 *   jdk8以后 lambda表达式
 */
public class T02_HowToCreateThread {
    //继承Thread类
    //实现Runnabale
    //jdk8以后 lambda表达式

    static class MyThread extends Thread{
        @Override
        public void run(){
            System.out.println("MyThread: "+Thread.currentThread().getName());
        }
    }
    static class MyThread2 implements Runnable{
        @Override
        public void run() {
            System.out.println("MyThread2: "+Thread.currentThread().getName());
        }
    }
    public static void main(String[] args) {
        //继承Thread类
        new Thread(new MyThread()).start();
        new MyThread().start();

        //实现runnable接口
        new Thread(new MyThread2()).start();


        //lambda
        new Thread(()->{
            System.out.println("runnable: " + Thread.currentThread().getName());
        }).start();
    }
}

